import request from '@/utils/request'
import { getToken } from '@/utils/auth'

export function getAllConsoleUserList() {
  return request({
    url: '/ConsoleUser/all',
    method: 'get'
  })
}

export function getAllConsoleUserExceptRecommend() {
  return request({
    url: '/ConsoleUser/all/exceptUsereGroup2',
    method: 'get'
  })
}

export function getInfo() {
  return request({
    url: '/ConsoleUser/',
    method: 'get',
    params: {
      userId: getToken()
    }
  })
}

export function getName(userId) {
  return request({
    url: '/ConsoleUser/',
    method: 'get',
    params: {
      userId: userId
    }
  })
}

export function getConsoleUserById(id) {
  return request({
    url: '/ConsoleUser/',
    method: 'get',
    params: {
      userId: id
    }
  })
}

export function addUser1(consoleUser) {
  return request({
    url: '/ConsoleUser/append',
    method: 'post',
    data: {
      username: consoleUser.username,
      password: consoleUser.password,
      userGroup: consoleUser.userGroup,
      realname: consoleUser.realname,
      userPhone: consoleUser.userPhone,
      state: 0
    }
  })
}

export function addUser2(consoleUser) {
  return request({
    url: '/ConsoleUser/append',
    method: 'post',
    data: {
      username: consoleUser.username,
      password: '88888888',
      userGroup: 2,
      realname: consoleUser.realname,
      userPhone: consoleUser.userPhone,
      state: 0,
      accountId: consoleUser.accountId,
      accountName: consoleUser.accountName,
      bankName: consoleUser.bankName,
      education: consoleUser.education,
      email: consoleUser.email,
      file: consoleUser.file,
      idcard: consoleUser.idcard,
      level: 1,
      remarks: consoleUser.remarks,
      sex: consoleUser.sex,
      subordinateId: consoleUser.subordinateId
    }
  })
}

export function addUser3(consoleUser) {
  return request({
    url: '/ConsoleUser/append',
    method: 'post',
    data: {
      username: consoleUser.username,
      password: consoleUser.password,
      userGroup: consoleUser.userGroup,
      realname: consoleUser.realname,
      orgId: consoleUser.orgId,
      userPhone: consoleUser.userPhone,
      state: 0
    }
  })
}

export function addUser4(consoleUser) {
  return request({
    url: '/ConsoleUser/append',
    method: 'post',
    data: {
      username: consoleUser.username,
      password: consoleUser.password,
      userGroup: consoleUser.userGroup,
      realname: consoleUser.realname,
      userPhone: consoleUser.userPhone,
      state: 0
    }
  })
}

export function deleteUser(id) {
  return request({
    url: '/ConsoleUser/remove',
    method: 'get',
    params: {
      userId: id
    }
  })
}

export function updateUser1(consoleUser) {
  return request({
    url: '/ConsoleUser/user',
    method: 'put',
    params: {
      userId: consoleUser.userId,
      username: consoleUser.username,
      password: consoleUser.password,
      userGroup: consoleUser.userGroup,
      realname: consoleUser.realname,
      userPhone: consoleUser.userPhone
    }
  })
}
export function updateUser2(consoleUser) {
  return request({
    url: '/ConsoleUser/user',
    method: 'put',
    params: {
      userId: consoleUser.userId,
      username: consoleUser.username,
      password: consoleUser.password,
      userGroup: consoleUser.userGroup,
      realname: consoleUser.realname,
      userPhone: consoleUser.userPhone,
      accountId: consoleUser.accountId,
      accountName: consoleUser.accountName,
      bankName: consoleUser.bankName,
      education: consoleUser.education,
      email: consoleUser.email,
      file: consoleUser.file,
      idcard: consoleUser.idcard,
      remarks: consoleUser.remarks,
      sex: consoleUser.sex,
      subordinateId: consoleUser.subordinateId
    }
  })
}
export function updateUser3(consoleUser) {
  return request({
    url: '/ConsoleUser/user',
    method: 'put',
    params: {
      userId: consoleUser.userId,
      username: consoleUser.username,
      password: consoleUser.password,
      userGroup: consoleUser.userGroup,
      realname: consoleUser.realname,
      orgId: consoleUser.orgId,
      userPhone: consoleUser.userPhone
    }
  })
}

export function conditionSearch(search) {
  return request({
    url: '/ConsoleUser/mohu/condition/search',
    method: 'post',
    data: {
      orgId: search.orgId,
      userGroup: search.userGroup,
      username: search.username
    }
  })
}

export function mohuSearch(str) {
  return request({
    url: '/ConsoleUser/mohu/search',
    method: 'post',
    data: {
      str: str
    }
  })
}

export function getUserByGroup(userGroup) {
  return request({
    url: '/ConsoleUser/all/head/reallyNameandName/userGroup',
    method: 'get',
    params: {
      userGroup: userGroup
    }
  })
}

export function getUserByGroup1(userGroup) {
  return request({
    url: '/ConsoleUser/userGroup1',
    method: 'get',
    params: {
      userGroup: userGroup
    }
  })
}

export function judgment(username) {
  return request({
    url: '/ConsoleUser/judgment/userName',
    method: 'post',
    data: {
      userName: username
    }
  })
}

export function judgement(username, userId) {
  return request({
    url: '/ConsoleUser/judgment/update/userName',
    method: 'get',
    params: {
      userName: username,
      userid: userId
    }
  })
}

export function judgement2(username) {
  return request({
    url: '/ConsoleUser/judgment/update/userName',
    method: 'get',
    params: {
      userName: username,
      userid: getToken()
    }
  })
}

export function getUserById(id) {
  return request({
    url: '/ConsoleUser/all/head/reallyNameandName/userId',
    method: 'get',
    params: {
      userId: id
    }
  })
}

export function resetPwd(userId) {
  return request({
    url: '/ConsoleUser/pwd',
    method: 'post',
    data: {
      userId: userId,
      pwd: 88888888
    }
  })
}

export function getRecommend() {
  return request({
    url: '/ConsoleUser/id/subordinate',
    method: 'post',
    data: {
      userId: getToken()
    }
  })
}

export function addRecommend(consoleUser) {
  return request({
    url: '/ConsoleUser/add/subordinate',
    method: 'post',
    data: {
      username: consoleUser.username,
      password: '88888888',
      userGroup: 2,
      realname: consoleUser.realname,
      userPhone: consoleUser.userPhone,
      state: 0,
      accountId: consoleUser.accountId,
      accountName: consoleUser.accountName,
      bankName: consoleUser.bankName,
      education: consoleUser.education,
      email: consoleUser.email,
      file: consoleUser.file,
      idcard: consoleUser.idcard,
      level: 1,
      remarks: consoleUser.remarks,
      sex: consoleUser.sex,
      subordinateId: consoleUser.subordinateId,
      postUserId: getToken(),
      userId: getToken(),
      agentAuditOperation: 1
    }
  })
}

export function searchRecommend(search) {
  return request({
    url: '/ConsoleUser/userGroup2/mohuSearch',
    method: 'get',
    params: {
      str: search.realName
    }
  })
}

export function searchSubordinateRecommend(search) {
  return request({
    url: '/ConsoleUser/id/subordinateMohuSearch',
    method: 'post',
    data: {
      str: search.realName,
      userId: getToken()
    }
  })
}

export function updateStatus(id) {
  return request({
    url: '/ConsoleUser/user',
    method: 'put',
    params: {
      userId: id,
      operationStatus: 0
    }
  })
}

export function updateStatus2(id) {
  return request({
    url: '/ConsoleUser/user',
    method: 'put',
    params: {
      userId: id,
      operationStatus: 1
    }
  })
}

export function getLeader() {
  return request({
    url: '/ConsoleUser/all/2',
    method: 'get'
  })
}
